var getEare = function(){
    $.ajax({
        url: "/rm/siteInfo/getAll",
        type:"post",
        dataType: 'json',
        // contentType:'application/json',
        // data:paramData,
        success: function(result){
            if(result.status === 0){
                // layer.msg(result.msg);
                console.log(result)
                for (var i = 0;i<result.data.length;i++){
                    console.log(1111)
                    var str = `<tr>
                        <td><input type="checkbox"></td>
                        <td>${result.data[i].id}</td>
                        <td><input type="text" value="${result.data[i].troops}"></td>
                        <td><input type="text" value="${result.data[i].startTime}"></td>
                        <td><input type="text" value="${result.data[i].finishTime}"></td>
                        <td><input type="text" value="${result.data[i].developUnit}"></td>
                        <td><input type="text" value="${result.data[i].state}"></td>
                        <td><button onclick="saveEdit(this)">保存</button></td>
                    </tr>`
                    $('tbody').append(str)
                }

            }else{
                console.log(232222)
            }
        }, //处理完成
        error: function(res){

        },
        complete:function(){
            // layer.close(layerLoad);
        },
    });
}
getEare();
var deleteEdit = function(){
    var unshift = '';
    for (let i = 0 ;i<$('tbody :checked').length; i++){
        unshift+=Number($('tbody :checked').eq(i).parent().next().text())
    }
    console.log(unshift);
    $.ajax({
        url: "/rm/siteInfo/removeById",
        type:"post",
        data:{'ids':unshift},
        success: function(result){
            console.log(111)
        }, //处理完成
        error: function(res){
            console.log(1111111111)

        },
        complete:function(){
            // layer.close(layerLoad);
        },
    });
};

var saveEdit = function(_this){
    var json = {"id":Number($(_this).parent().siblings('td').eq(1).text()),"troops":$(_this).parent().siblings('td').eq(2).find('input').val(),"startTime":$(_this).parent().siblings('td').eq(3).find('input').val(),"finishTime":$(_this).parent().siblings('td').eq(4).find('input').val(),"developUnit":$(_this).parent().siblings('td').eq(5).find('input').val(),"state":$(_this).parent().siblings('td').eq(6).find('input').val()};
    console.log(json);
    $.ajax({
        url: "/rm/siteInfo/saveSite",
        type:"post",
        data:json,
        success: function(result){
            console.log(111)
        }, //处理完成
        error: function(res){
            console.log(1111111111)

        },
        complete:function(){
            // layer.close(layerLoad);
        },
    });
}